package blog.spring.db.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import blog.core.util.DaoUtils;
import blog.spring.db.dao.IArticleDAO;
import blog.spring.db.dao.ILableDAO;
import blog.spring.db.entity.ArticleInfo;
import blog.spring.db.entity.Lable;
import blog.spring.db.service.IArticleService;
import blog.spring.db.service.ILableService;

@Controller("lableService")
public class LableService extends BaseService<Lable> implements ILableService {

	public static String TYPE_NAME = "标签";
	private final ILableDAO lableDao;
	@Resource
	private IArticleDAO articleDao;

	@Autowired
	public LableService(ILableDAO lableDao) {
		super(lableDao, TYPE_NAME);
		this.lableDao = lableDao;
	}

	@Override
	public List<ArticleInfo> findListArticles(int id, Integer pageNum,
			Integer pageSize, String name, String sort) {
		String hql = "select t from ArticleInfo as t join t.lables as l where l.lableId = "
				+ id;
		return articleDao.searchListWithTheBasicHql(hql, null, pageNum,
				pageSize, sort, name, false);
	}

}
